package com.easyj.admin.activiti.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.easyj.admin.activiti.service.ActTaskService;
import com.easyj.admin.activiti.vo.TaskQO;
import com.easyj.admin.activiti.vo.TaskVO;
import com.easyj.base.common.ajax.Result;
import com.easyj.base.common.page.Page;
import com.easyj.base.controller.BaseController;
import com.easyj.base.exception.EasyjException;

/**
 * 查询本人任务
 * @author hjf
 *
 */
@RestController
@RequestMapping(value = "/task")
public class TaskController extends BaseController{
	
	@Autowired
	private ActTaskService actTaskService;
	
	@PostMapping(value = "findRuntimeTasks")
	public Result findRuntimeTasks(@RequestBody  TaskQO filter) {
		Page<TaskVO> page=actTaskService.findRuntimeTasks(filter);
		return Result.Success(page);
	}
	
	@PostMapping(value = "findHistoryTasks")
	public Result findHistoryTasks(@RequestBody  TaskQO filter) {
		Page<TaskVO> page=actTaskService.findHistoryTasks(filter);
		return Result.Success(page);
	}
	
	
	@GetMapping(value = "getRuntimeTaskCount")
	public Result getRuntimeTaskCount() {
		long count=actTaskService.getRuntimeTaskCount();			
		return Result.Success(count);
	}
	
	@GetMapping(value = "getHistoryTaskCount")
	public Result getHistoryTaskCount() {
		long count=actTaskService.getHistoryTaskCount();			
		return Result.Success(count);
	}
	
	
	 /**
		 完成抄送任务
	 * @throws EasyjException 
		*/
	@RequestMapping(value = "completeNotifyTask", method = RequestMethod.GET)
	public Result completeNotifyTask(@RequestParam(value = "id") String id){
		actTaskService.completeNotifyTask(id);
		return Result.Success();
	}
	
}
